/**
 * 测试接口
 */
import BaseController from "../common/BaseController"
import SMSController from "./SMSController"

class TestController extends BaseController {
    constructor() {
        super()
        this.mainMethod = this.mainMethod.bind(this)
        this.state = {
            request: null,
            response: null,
            next: null,
        }
    }

    mainMethod (req, res, next) {
        this.state.request = req
        this.state.response = res
        this.state.next = next
        this.handleReturnInWorkTable()
    }

    async handleReturnInWorkTable () {
        const { response, request } = this.state
        let token = request.headers.authorzation

        //token验证
        const verifyTokenMiddle = await this.verifyTokenMiddle(token, response)
        // token验证失败；token过期
        if (verifyTokenMiddle.status == -2) {
            response.json({
                code: -2,
                msg: verifyTokenMiddle.msg,
            })
            return
        }
        // SMSController({ phone:'18286044741' })
        // SMSController().then((smsresult) => {
        //     response.json(smsresult)
        // }).catch((error) => {
        //     response.json(error)
        // })
    }
}

export default new TestController().mainMethod
